package com.ruoyi.deeplearn.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.deeplearn.domain.DeepTagGroup;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.deeplearn.domain.DeepDatasetType;
import com.ruoyi.deeplearn.service.IDeepDatasetTypeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 数据集类型Controller
 *
 * @author 任伟伟
 * @date 2022-12-10
 */
@Deprecated
@RestController
@RequestMapping("/deeplearn/datasettype")
public class DeepDatasetTypeController extends BaseController
{
    @Autowired
    private IDeepDatasetTypeService deepDatasetTypeService;

    /**
     * 查询数据集类型列表
     */
    @PreAuthorize("@ss.hasPermi('deeplearn:datasettype:list')")
    @GetMapping("/list")
    public TableDataInfo list(DeepDatasetType deepDatasetType)
    {
        startPage();
        List<DeepDatasetType> list = deepDatasetTypeService.selectDeepDatasetTypeList(deepDatasetType);
        return getDataTable(list);
    }

    @PreAuthorize("@ss.hasPermi('deeplearn:datasettype:list')")
    @GetMapping("/list/all")
    public AjaxResult listAll(DeepDatasetType deepDatasetType)
    {
        List<DeepDatasetType> list = deepDatasetTypeService.selectDeepDatasetTypeList(deepDatasetType);
        return success(list);
    }

    /**
     * 导出数据集类型列表
     */
    @PreAuthorize("@ss.hasPermi('deeplearn:datasettype:export')")
    @Log(title = "数据集类型", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DeepDatasetType deepDatasetType)
    {
        List<DeepDatasetType> list = deepDatasetTypeService.selectDeepDatasetTypeList(deepDatasetType);
        ExcelUtil<DeepDatasetType> util = new ExcelUtil<DeepDatasetType>(DeepDatasetType.class);
        util.exportExcel(response, list, "数据集类型数据");
    }

    /**
     * 获取数据集类型详细信息
     */
    @PreAuthorize("@ss.hasPermi('deeplearn:datasettype:query')")
    @GetMapping(value = "/{typeId}")
    public AjaxResult getInfo(@PathVariable("typeId") Long typeId)
    {
        return success(deepDatasetTypeService.selectDeepDatasetTypeByTypeId(typeId));
    }

    /**
     * 新增数据集类型
     */
    @PreAuthorize("@ss.hasPermi('deeplearn:datasettype:add')")
    @Log(title = "数据集类型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DeepDatasetType deepDatasetType)
    {
        return toAjax(deepDatasetTypeService.insertDeepDatasetType(deepDatasetType));
    }

    /**
     * 修改数据集类型
     */
    @PreAuthorize("@ss.hasPermi('deeplearn:datasettype:edit')")
    @Log(title = "数据集类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DeepDatasetType deepDatasetType)
    {
        return toAjax(deepDatasetTypeService.updateDeepDatasetType(deepDatasetType));
    }

    /**
     * 删除数据集类型
     */
    @PreAuthorize("@ss.hasPermi('deeplearn:datasettype:remove')")
    @Log(title = "数据集类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{typeIds}")
    public AjaxResult remove(@PathVariable Long[] typeIds)
    {
        return toAjax(deepDatasetTypeService.deleteDeepDatasetTypeByTypeIds(typeIds));
    }
}
